#ifndef ACCOUNTSTATEOVERDRAFT_H__
#define ACCOUNTSTATEOVERDRAFT_H__

//include header
#include "AccountState.h"

//using namespace
using namespace std;


namespace npState
{
    //class forward declaration
    
    class AccountStateOverdraft : public AccountState
        //,public covariant
    {
        //friend
        
        //embedded type
        
        //class skeleton
        public: AccountStateOverdraft();
        public: AccountStateOverdraft(const AccountStateOverdraft& cpy);
        public: AccountStateOverdraft(AccountStateOverdraft&& mov) noexcept;
        public: virtual ~AccountStateOverdraft();
        public: AccountStateOverdraft& operator=(const AccountStateOverdraft& asn);
        public: AccountStateOverdraft& operator=(AccountStateOverdraft&& mva) noexcept;
        public: virtual shared_ptr<covariant> clone() const throw();
        public: virtual shared_ptr<covariant> steal(void* sft=nullptr) throw();

        //other constructors
        public: explicit AccountStateOverdraft(weak_ptr<Account> account);
        
        //public methods
        public: virtual void deposit(double amount) throw(AccountState::ErrorEnum);
        public: virtual void withdraw(double amount) throw(AccountState::ErrorEnum);
        public: virtual void calcInterest() throw(AccountState::ErrorEnum);
        public: virtual void stateCheck() throw(AccountState::ErrorEnum);
        public: virtual string toString() const throw();
        
        //protected methods
        
        //private methods
        
        //protected data
        /* 类中不应该存在protected 访问级别的data
         * 要么私有，要么私有而后给出protected 访问级别的methods !!! */
        
        //private data
        /* 类中不应存在指针类型成员，
         * 取而代之，应使用智能指针予以包裹
         * 使用shared_ptr表示类拥有指针指向对象
         * 使用weak_ptr表示类仅可以使用指针指向对象
         * 智能指针对指针成员的封装和使用准则：
         * 1.类对象不允许使用unique_ptr包裹
         * 2.推敲业务逻辑，如果是共享的(share_ptr)，则尽可能少的共享指针对象
         * 3.如果从业务逻辑中发现类仅仅使用某个指针所指对象，则务必使用weak_ptr包裹指针，
         *   以此切实地描述这种使用而不拥有的关系
         * 4.类成员weak_ptr<*> ths，由其产生的，包裹this指针的，shared_ptr只允许在局部使用 */
        
        //static part
        
        //others
    };

    //inline functions
    inline AccountStateOverdraft::AccountStateOverdraft() : AccountState()
    {
        
    }
    
    inline AccountStateOverdraft::AccountStateOverdraft(const AccountStateOverdraft& cpy) : AccountState(cpy)
    {
        
    }
    
    inline AccountStateOverdraft::AccountStateOverdraft(AccountStateOverdraft&& mov) noexcept : AccountState(move(mov))
    {
        
    }
    
    inline AccountStateOverdraft::~AccountStateOverdraft()
    {
        
    }
    
    inline AccountStateOverdraft& AccountStateOverdraft::operator=(const AccountStateOverdraft& asn)
    {
        if (this == &asn)
        {
            return *this;
        }
        else
        {
            AccountState::operator=(asn);
            
            //To do
            
            return *this;
        }
    }
    
    inline AccountStateOverdraft& AccountStateOverdraft::operator=(AccountStateOverdraft&& mva) noexcept
    {
        if (this == &mva)
        {
            return *this;
        }
        else
        {
            AccountState::operator=(move(mva));
            
            //To do
            
            return *this;
        }
    }
    
    inline shared_ptr<covariant> AccountStateOverdraft::clone() const throw()
    {
        //new an instance if not abstract.
        return make_shared<AccountStateOverdraft>(*this);
    }
    
    inline shared_ptr<covariant> AccountStateOverdraft::steal(void* sft) throw()
    {
        AccountStateOverdraft* shf = static_cast<AccountStateOverdraft*>(sft);
        if (this == shf)
        {
            return shared_ptr<covariant>();
        }
        else
        {
            shared_ptr<AccountStateOverdraft> ret;
            if (!shf)
            {
                //new an instance if not abstract.
                ret = make_shared<AccountStateOverdraft>();
                shf = ret.get();
            }
            
            AccountState::steal(shf);
            
            //To do
            
            return ret;
        }
    }
} // namespace npState


#endif //ACCOUNTSTATEOVERDRAFT_H__
